<template>
  <el-form size="mini" :model="gms" :inline="true">
    <el-form-item v-for="(val, key) in gms" :key="key">
      <el-button @click="gmContent(key)">{{ val }}</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import { gmContentReq, gmReq } from "../api/req";
export default {
  data() {
    let gms = {
      1: "hello",
      2: "world",
    };
    return { gms: gms };
  },
  created() {
    gmReq().then((res) => {
      this.gms = res;
    });
  },
  methods: {
    gmContent(type) {
      let obj = {
        type: type,
      };
      gmContentReq(obj).then((res) => {
        delete res.describe;
        let domains = [];
        for (let key in res) {
          let value = "";
          if (key == 'type')
            value = res[key];
          domains.push({
            label: key,
            value: value,
          });
        }
        this.$store.commit('changeGmContent', domains);
      });
    },
  },
};
</script>